<div class="maintop">
	当前位置：广告管理
	<a href="javascript:;" action="<?=$basepath?>_add?<?=$this->page_url($page_current,$page_url)?>" class="mainFrame button icon-plus">添加广告</a>
	<a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($page_current,$page_url)?>" class="mainFrame button">刷新</a>
    <a action="/cache/update?keys=game_home_banners" title="更新缓存" class="mainFrame button icon-undo" href="javascript:;">更新缓存</a>
</div>
<div class="main-search">
            <table width="100%">
                <tbody><tr>
                    <td>
                        <form action="<?=$basepath?>" id="brandsSearch" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                            <select id="categoryid" name="categoryid">
                                <option value="" selected="selected">全部分类</option>
                                <? foreach($category as $k=>$v){ ?>
                                    <option value="<?=$k?>"><?=$v?></option>
                                <? } ?>
                            </select>
                            <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字" value="<?=$this->existsKeyInArray('sKey',$searchdata,'S')?>" />
                            每页：
                            <select id="ps" name="ps">
                                <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                                <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                                <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                                <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                                <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                            </select>
                            <input type="submit" value="搜索" class="upbutton">
                        </form>
                    </td>
                </tr>
            </tbody></table>
</div>
<div id="mainbody">
	<table width="100%" class="tablist">
	<tr class="trbg"><th colspan="2">广告名称</th><th width="320">图片</th><th width="200">广告分类</th><th width="260">广告时间</th><th width="60">操作</th></tr>
	<? foreach($datas as $v){ ?>
	<tr>
	<td width="30"><?=$v['id']?></td>
	<td class="tdleft"><?=$v['title']?></td>
    <td><img src="<?=($v['pic']!="#" ? $v['pic'] : IMG.'nopic.png') ?>" height="20" border="0" /></td>
	<td><?=$category[$v['categoryid']]?></td>
    <td><?=date('Y-m-d H:i:s',$v['actiontime'])?> - <?=($v['endtime'] ? date('Y-m-d H:i:s',$v['endtime']) : '无结束时间')?></td>
	<td>
		<a action="<?=$basepath?>_delete?id=<?=$v['id']?>&<?=$this->page_url($page_current,$page_url)?>" title="删除" class="mainFrame button icon-trash-2" href="javascript:;"></a>
		<a action="<?=$basepath?>_edit?id=<?=$v['id']?>&<?=$this->page_url($page_current,$page_url)?>" title="编辑" class="mainFrame button icon-edit" href="javascript:;"></a>
	</td>
    </tr>
	<? } ?>
    </table>
    <? require VIEW.'/page.view.php' ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){
        var _key = this.sKey.value;
        if(_key.length<=0){
            //throw '搜索关键字不能为空';
        }
    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['categoryid'])){
            echo '$("#categoryid option[value=\''.$searchdata['categoryid'].'\']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        ?>

    });
</script>
